// UserStatus.cs
// Facebook/Framework/Service
// Copyright (c) 2007, Nikhil Kothari. All Rights Reserved.
//

using System;
using System.Collections;
using System.Diagnostics;
using Facebook.Service.Core;

namespace Facebook.Service {

    /// <summary>
    /// Represents the status information on the user's profile.
    /// </summary>
    public sealed class UserStatus : FacebookEntity {

        private bool _updateDateTransformed;

        internal UserStatus(Hashtable statusState)
            : base(statusState) {
        }

        /// <summary>
        /// The status message if any.
        /// </summary>
        public string Message {
            get {
                return GetState<string>("message") ?? String.Empty;
            }
        }

        /// <summary>
        /// The date/time stamp of the status message if any.
        /// </summary>
        public DateTime UpdateDate {
            get {
                if (_updateDateTransformed == false) {
                    return TransformUpdateDate();
                }
                return (DateTime)this["time"];
            }
        }

        private DateTime TransformUpdateDate() {
            Debug.Assert(_updateDateTransformed == false);

            DateTime updateDate = FacebookResponse.CoerceDateTime(this["time"]);

            this["time"] = updateDate;
            _updateDateTransformed = true;

            return updateDate;
        }
    }
}
